Skip to content

fix: grant coder user ownership of /nix for single-user mode#12

Merged
megheaiulian merged 1 commit intomainfrom
fix/nix-store-permissions
Feb 10, 2026
Merged

fix: grant coder user ownership of /nix for single-user mode#12
megheaiulian merged 1 commit intomainfrom
fix/nix-store-permissions

Conversation

@megheaiulian
Copy link
Contributor

Summary

  • Fixes Permission denied error when running nix develop (or any Nix command that needs store access) as the coder user
  • Adds chown -R 1000:1000 ./nix in fakeRootCommands so the coder user owns the entire /nix tree, allowing single-user Nix operations to acquire locks and write to the store/db without a daemon

Problem

The image is built with buildLayeredImageWithNixDb, which populates the Nix database at build time. The /nix/var/nix/db/ directory ends up owned by root, but the container runs as user coder (uid 1000). In single-user mode (no Nix daemon), Nix commands need direct write access to the store and database, resulting in:

error: opening lock file '/nix/var/nix/db/big-lock': Permission denied

The Nix store database (/nix/var/nix/db/) is owned by root after image
build, causing 'Permission denied' when the coder user runs nix commands
like 'nix develop'. Grant ownership of the entire /nix tree to the coder
user (uid 1000) so single-user Nix operations can acquire locks and
write to the store without requiring a daemon.
@megheaiulian megheaiulian merged commit b20690c into main Feb 10, 2026
3 checks passed
@megheaiulian megheaiulian deleted the fix/nix-store-permissions branch February 10, 2026 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant